// DBManager.cpp: implementation of the DBManager class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "DBManager.h"
#include "PDMSPerObjManager.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

namespace PDMS
{
	namespace PDMSFrame
	{
		DBManager::DBManager()
		{
			
		}
		
		DBManager::~DBManager()
		{
			
		}

		PDMSPerObjManager* DBManager::GetDatabase( const Configration* pConfig )
		{
//			ASSERT( !strDBName.IsEmpty() );
			ASSERT( pConfig );

			PDMSPerObjManager* pManager = GetManaged( pConfig->DBName() );
			if ( pManager == NULL )
			{
				pManager = new PDMSPerObjManager;
				pManager->Name( pConfig->DBName() );
				pManager->SetModelType( pConfig->GetModelType() );
				
				UESoft::ErrorStatus es = pManager->Create();
				if ( es != UESoft::eOk )
				{
					delete pManager;
					return NULL;
				}

				Add( pConfig->DBName(), pManager );
			}
			return pManager;
		}
	}
}
